﻿namespace BEGDC.CC.Web.UserControls.CV
{
	using System;
	using System.Data;
	using System.Drawing;
	using System.Web;
	using System.Web.UI.WebControls;
	using System.Web.UI.HtmlControls;

	/// <summary>
	///	Summary description for PrintCtrl.
	/// </summary>
	public class CVPrintCtrl : System.Web.UI.UserControl
	{
		protected System.Web.UI.HtmlControls.HtmlGenericControl Btn_Print;

		private string _processType = string.Empty;
		public string ProcessType
		{
			get{ return _processType; }
			set{ _processType = value; }
		}

		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
			switch(this.ProcessType)
			{
				case "OCV":
					this.Btn_Print.Attributes["onclick"] = "javascript:OpenOCVPrintForm("+Request.QueryString["AppID"]+");";
					break;
				case "OCR":
					this.Btn_Print.Attributes["onclick"] = "javascript:OpenOCRPrintForm("+Request.QueryString["AppID"]+");";
					break;
				case "OCR_Feedback":
					this.Btn_Print.Attributes["onclick"] = "javascript:OpenOCRFeedbackPrintForm("+Request.QueryString["AppID"]+");";
					break;
				case "CV_Feedback":
					this.Btn_Print.Attributes["onclick"] = "javascript:OpenCVFeedbackPrintForm("+Request.QueryString["AppID"]+");";
					break;
					//add by zhaosong
				case "EBDCV":
					this.Btn_Print.Attributes["onclick"] = "javascript:OpenEBDCVPrintForm("+Request.QueryString["AppID"]+");";
					break;
				case "EBD":
					this.Btn_Print.Attributes["onclick"] = "javascript:OpenEBDPrintForm("+Request.QueryString["AppID"]+");";
					break;
				case "EBD_Feedback":
					this.Btn_Print.Attributes["onclick"] = "javascript:OpenEBDFeedbackPrintForm("+Request.QueryString["AppID"]+");";
					break;
				case "ESCCV":
					this.Btn_Print.Attributes["onclick"] = "javascript:OpenESCCVPrintForm("+Request.QueryString["AppID"]+");";
					break;
				case "ESC":
					this.Btn_Print.Attributes["onclick"] = "javascript:OpenESCPrintForm("+Request.QueryString["AppID"]+");";
					break;
				case "ESC_Feedback":
					this.Btn_Print.Attributes["onclick"] = "javascript:OpenESCFeedbackPrintForm("+Request.QueryString["AppID"]+");";
					break;
                default:
                    {
                        string pdType = Request.QueryString["PDType"];
                        if (string.IsNullOrEmpty(pdType))
                            throw new Exception("Unknown PDType!");
                        //this.Btn_Print.Attributes["onclick"] = "javascript:OpenPrintForm(" + Request.QueryString["AppID"] + ");";
                        //break;
                        switch (pdType)
                        {
                            case "EV":
                                this.Btn_Print.Attributes["onclick"] = "javascript:OpenPrintForm(" + Request.QueryString["AppID"] + ");";
                                break;
                            case "CR":
                                this.Btn_Print.Attributes["onclick"] = "javascript:OpenPrintForm(" + Request.QueryString["AppID"] + ");";
                                break;
                            case "OCV":
                                this.Btn_Print.Attributes["onclick"] = "javascript:OpenOCVPrintForm(" + Request.QueryString["AppID"] + ");";
                                break;
                            case "OCR":
                                if(!IsFeedBack())
                                    this.Btn_Print.Attributes["onclick"] = "javascript:OpenOCRPrintForm(" + Request.QueryString["AppID"] + ");";
                                else
                                    this.Btn_Print.Attributes["onclick"] = "javascript:OpenOCRFeedbackPrintForm(" + Request.QueryString["AppID"] + ");";
                                break;
                            //case "OCR_Feedback":
                            //    this.Btn_Print.Attributes["onclick"] = "javascript:OpenOCRFeedbackPrintForm(" + Request.QueryString["AppID"] + ");";
                            //    break;
                            //case "CV_Feedback":
                            //    this.Btn_Print.Attributes["onclick"] = "javascript:OpenCVFeedbackPrintForm(" + Request.QueryString["AppID"] + ");";
                            //    break;
                            //add by zhaosong
                            case "EBDCV":
                                this.Btn_Print.Attributes["onclick"] = "javascript:OpenEBDCVPrintForm(" + Request.QueryString["AppID"] + ");";
                                break;
                            case "EBD":
                                if(!IsFeedBack())
                                    this.Btn_Print.Attributes["onclick"] = "javascript:OpenEBDPrintForm(" + Request.QueryString["AppID"] + ");";
                                else
                                    this.Btn_Print.Attributes["onclick"] = "javascript:OpenEBDFeedbackPrintForm(" + Request.QueryString["AppID"] + ");";
                                break;
                            //case "EBD_Feedback":
                            //    this.Btn_Print.Attributes["onclick"] = "javascript:OpenEBDFeedbackPrintForm(" + Request.QueryString["AppID"] + ");";
                            //    break;
                            case "ESCCV":
                                this.Btn_Print.Attributes["onclick"] = "javascript:OpenESCCVPrintForm(" + Request.QueryString["AppID"] + ");";
                                break;
                            case "ESC":
                                if (!IsFeedBack())
                                    this.Btn_Print.Attributes["onclick"] = "javascript:OpenESCPrintForm(" + Request.QueryString["AppID"] + ");";
                                else
                                    this.Btn_Print.Attributes["onclick"] = "javascript:OpenESCFeedbackPrintForm(" + Request.QueryString["AppID"] + ");";
                                break;
                            //case "ESC_Feedback":
                            //    this.Btn_Print.Attributes["onclick"] = "javascript:OpenESCFeedbackPrintForm(" + Request.QueryString["AppID"] + ");";
                            //    break;
                            default:
                                throw new Exception(string.Format("Unknown PDType {0}!",pdType) );
                        }

                        break;
                    }
			}

		}

        private bool IsFeedBack()
        {
            if (this.Page is Workflow.WorkflowExecution)
                return (this.Page as Workflow.WorkflowExecution).IsFeedBack;
            else if (this.Page is Workflow.WorkflowView)
                return (this.Page as Workflow.WorkflowView).IsFeedBack;
            else
                throw new Exception("Parent Page must be WorkflowExecution or WorkflowView");
                
        }

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		///	Required method for Designer support - do not modify
		///	the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.Load += new System.EventHandler(this.Page_Load);
		}

		#endregion
	}
}
